<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>会员级别</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../script/jquery.validation.min.js"></script>
<script type="text/javascript" src="../script/my_lightbox.js"></script>
<script>
$(function(){
	$('#form').validate({
		errorPlacement: function(error, element){
			element.next('.form-error').append(error);
		},      
		rules : {
			name:{
				required:true
			},
			demand:{
				digits:true
			},
			valid:{
				digits:true
			},
			sum:{
				number:true
			},
			rate:{
				number:true
			}
			
		},
		messages : {
			name:{
				required:"请填写级别名称",
			},
			demand:{
				digits:"必须输入整数"
			},
			valid:{
				digits:"必须输入整数"
			},
			sum:{
				number:"必须输入合法的数字"
			},
			rate:{
				number:"必须输入合法的数字"
			}
		}
	});
});
</script>
</head>
<body>
	<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>会员级别</h3>
                <ul>
                    <li <{if $smarty.get.operation==''}>class="current"<{/if}>><a href="?m=member&s=grade.php"><span>管理</span></a></li>
                    <li <{if $smarty.get.operation=='add'}>class="current"<{/if}>><a href="?m=member&s=grade.php&operation=add"><span>添加</span></a></li>
                    <{if $smarty.get.operation=='edit'}>
                    <li class="current"><a href="#"><span>修改</span></a></li>
                    <{/if}>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <{if $smarty.get.operation=='add' or $smarty.get.operation=='edit' }>
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" id="id" value="<{$de.id}>">
            <table class="table">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">会员级别</th>
                    </tr>
                </thead>
                
                <tbody>
                <tr>
                    <td width="100">级别名称</td>
                    <td>
                    <input name="name" id="name" type="text" class="w350" value="<{$de.name}>"><div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <{if $de.id!=1}>
                <tr>
                    <td>条件</td>
                    <td>
                    <input name="demand" id="demand" type="text" class="w350" value="<{if $de.demand}><{$de.demand}><{else}>0<{/if}>"><div id="form-error" class="form-error"></div>
                   </td>
                </tr>
                <{else}>
                <input name="demand" type="hidden" value="<{$de.demand}>">
                <{/if}>
                
                <{if $de.id!=1}>
                <tr>
                    <td>有效期</td>
                    <td>
                    <input name="valid" id="valid" type="text" class="w350" value="<{if $de.valid}><{$de.valid}><{else}>0<{/if}>"><div id="form-error" class="form-error"></div><p>单位：年 为0时，无限期</p>
                    </td>
                </tr>
                <{else}>
                <input name="valid" type="hidden" value="<{$de.valid}>">
                <{/if}>
                
                <{if $de.id!=1}>
                <tr>
                    <td>年费</td>
                    <td>
                    <input name="sum" id="sum" type="text" class="w350" value="<{if $de.sum}><{$de.sum}><{else}>0<{/if}>"><div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                <{else}>
                <input name="sum" type="hidden" value="<{$de.sum}>">
                <{/if}>
                
                <tr>
                    <td>小图</td>
                    <td>
                    <input name="logo" type="text" id="logo" class="w350" value="<{$de.logo}>">
                    [<a href="javascript:uploadfile('上传LOGO','logo',17,17,'')">上传</a>] 
                    [<a href="javascript:preview('logo');">预览</a>]
                    [<a onclick="javascript:$('#logo').val('');" href="#">删除</a>]
                    </td>
                </tr>
                
                <tr>
                    <td>大图</td>
                    <td>
                    <input name="blogo" type="text" id="blogo" class="w350" value="<{$de.blogo}>">
                    [<a href="javascript:uploadfile('上传LOGO','blogo',65,65,'')">上传</a>] 
                    [<a href="javascript:preview('blogo');">预览</a>]
                    [<a onclick="javascript:$('#blogo').val('');" href="#">删除</a>]
                    </td>
                </tr>
                
                <tr>
                    <td>折扣率</td>
                    <td>
                    <input name="rate" id="rate" type="text" class="w350" value="<{if $de.rate}><{$de.rate}><{else}>0<{/if}>"><div id="form-error" class="form-error"></div>
                    </td>
                </tr>
				<script charset="utf-8" src="<{$config.weburl}>/lib/kindeditor/kindeditor-min.js"></script>
                <script>
                var editor;
                KindEditor.ready(function(K) {editor = K.create('textarea[name="treatment"]', {});});
                </script>
                <tr>
                    <td>权益</td>
                    <td><textarea style="width:100%" class="w343" name="treatment"><{$de.treatment}></textarea></td>
                </tr>

                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<{if !$smarty.get.editid}>save<{else}>edit<{/if}>">
                    </td>
                </tr>
                
                </tbody>
            </table>
            </form>
        <{else}>
		<script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });	 
        });
        </script>
        <form action="" method="post">
        <table class="table">
            <tbody>
                <tr class="header partition">
                    <th width="30"></th>
                    <th width="130">名称</th>
                    <th width="150">条件</th>
                    <th width="90">有效期</th>
                    <th width="90">年费</th>
                    <th width="90">折扣率</th>
                    <th>权益</th>
                    <th width="50"></th>
                </tr>
                <{foreach item=list from=$de.list}>
                <tr>
                    <td><input type="checkbox" <{if $list.id==1}>disabled="disabled"<{/if}> value="<{$list.id}>" class="checkitem" name="chk[]"></td>
                    <td><{$list.name}></td>
                    <td><{if $list.id==1}>注册成功<{else}><{if $list.demand<=1}>购买过商品<{else}><{$list.demand}>(含)以上<{/if}><{/if}></td>
                    <td><{if $list.valid==0}>无限期<{else}><{$list.valid}>年<{/if}></td>
                    <td><{$config.money}><{$list.sum}></td>
                    <td><{$list.rate}>%</td>
                    <td><{$list.treatment|strip_tags|truncate:80}></td>
                    <td>
                    <a href="?m=member&s=grade.php&operation=edit&editid=<{$list.id}>"><{$editimg}></a> 
                    <{if $list.id!=1}><a onclick="return confirm('确定删除吗');" href="?m=member&s=grade.php&delid=<{$list.id}>"><{$delimg}></a><{/if}>
                    </td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <{/foreach}>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="2">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" value="提交" />
                    </td>
                    <td colspan="99"><div class="page"><{$de.page}></div></td>
                </tr>
            </tfoot>
        </table>
        </form>
        <{/if}>
    </div>
</body>
</html>